package com.learning.springboot.springdataJpa.controller;

import com.learning.springboot.Thymeleaf.entity.Person;
import com.learning.springboot.springdataJpa.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;

/**
 * Created by td on 2017/9/14.
 */
@RestController
@RequestMapping("/jpa")
public class controllert {
    @Autowired
    private PersonRepository personRepository;

    @Autowired
    private Environment environment;

    @GetMapping("/test")
    public Person testJpa(HttpSession session){
        
        Person person = new Person();
        String string = environment.getProperty("profile");

        System.out.println(string);
        person.setAge(1);
        person.setName("zhangsan");
        personRepository.save(person);

        return person;
    }
}
